package com.qidian.mespro.controller;

import com.github.pagehelper.PageInfo;
import com.qidian.mespro.service.WorkflowProcessService;
import com.qidianit.mes.pojo.Process;
import com.qidianit.mes.pojo.Result;
import com.qidianit.mes.pojo.WorkflowProcess;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ author: 周晓轩
 * @ company 起点编程
 * @ time: 2025/9/19 - 14:03
 * @ Description:
 */
@RestController
@RequestMapping("/workflowProcess")
public class WorkflowProcessController {
    @Autowired
    private WorkflowProcessService workflowProcessService;

    /**
     * 分页查询工艺的工序组成列表
     */
    @GetMapping("/page")
    public Result<PageInfo<WorkflowProcess>> getList(Long workflowId, @RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "10") int pageSize) {
        return workflowProcessService.selectList(workflowId, pageNum, pageSize);
    }

    @PostMapping("/add")
    public Result<WorkflowProcess> save(@RequestBody WorkflowProcess workflowProcess){
        return workflowProcessService.addWorkflowProcess(workflowProcess);
    }

    @GetMapping("/{id}")
    public Result<WorkflowProcess> getByID(@PathVariable("id") Long id){
        return workflowProcessService.selectWorkflowProcessById(id);
    }

    @PutMapping("/update")
    public Result update(@RequestBody WorkflowProcess workflowProcess){
        return workflowProcessService.updateWorkflowProcessById(workflowProcess);
    };

    @DeleteMapping("/delete/{id}")
    public Result deleteById(@PathVariable Long id){
        return workflowProcessService.deleteWorkflowProcessById(id);
    }

    @DeleteMapping("/batchDelete")
    public Result batchDelete(Long [] id){
        return workflowProcessService.batchDelete(id);
    };
}
